<!-- 首页展示数据 -->
<template>
  <div class="homeinfo">
    <!-- <van-loading size="48px" vertical v-show="show">加载中...</van-loading> -->
    <!-- <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
      offset="50"
    > -->
      <van-grid :column-num="2" icon-size="3.1rem">
        <van-grid-item
          v-for="item of special_offer"
          :key="item.id"
          :icon="item.goods_logo"
          @click="Details(item.id,item.goods_id)"
        />
      </van-grid>
    <!-- </van-list> -->
  </div>
</template>

<script>
export default {
  props:{
    special_offer:[Object,Array]
  },
  data() {
    return {
      page: 0,
      search: "", //
      total: 0, //总共的数据条数
      // list: [12], //展示的数组

      loading: false,
      finished: false,
      show: false
    };
  },
  created(){
    console.log(this.special_offer)
  },
  methods: {
    // onLoad() {
    //   this.page++;
    //   let search = this.search;
    //   // this.getinfo();
    //   console.log("下拉加载更多");
    // },
    // getinfo() {
    //   this.show = true;
    //   let search = this.search;
    //   let page = this.page;

    //   let res = this.$http({
    //     method: "post",
    //     url: "home/search_goods/index",
    //     data: {
    //       search,
    //       page
    //     }
    //   })
    //     .then(res => {
    //       this.show = false;
    //       // console.log(res);
    //       let rows = res.data.data.splice(0, 10); //请求返回当页的列表
    //       console.log(rows);
    //       this.loading = false;
    //       this.total = res.data.total;
    //       this.list = this.list.concat(rows);
    //       if (rows == null || rows.length < 10) {
    //         // 加载结束
    //         this.finished = true;
    //         return;
    //       }

    //       if (this.list.length >= this.total) {
    //         this.finished = true;
    //         return;
    //       }
    //     })
    //     .catch(err => {
    //       console.log(err);
    //     });
    // },
    //跳转详情
    Details(id, pid) {
      console.log(id, pid);
      this.$router.push({
        name: "detail",
        query: {
          id: id,
          pid: pid
        }
      });
    }
  }
};
</script>
<style lang='scss' scoped>
.homeinfo {
  margin-bottom: 1.3rem;
}
</style>